<template>
  <div>
    <h1 style="margin:10px auto;text-align:center;">创建行程</h1>
    <van-form ref="form" :model="form" :rules="rules" @submit="onSubmit">
      <van-cell-group prop="route">
        <van-field v-model="form.route" rows="1" type="textarea" autosize label="路线规划" placeholder="请输入" />
        <van-field v-model="form.type_id" label="几日" placeholder="请输入" />
      </van-cell-group>
      <div style="margin: 16px;">
        <van-button round block type="info" native-type="submit">提交</van-button>
        <van-button round block type="gray" style="margin-top:10px;" @click="$router.push('/explore')">返回</van-button>
      </div>
    </van-form>
  </div>
</template>

<script>
import httpApi from '@/http';
  export default {
    data() {
    return {
      form:{
        route:'',
        type_id:''
      },
      rules:{
       route:[{required:true,message:'必填',trigger:'blur'}],
      }
    };
  },
  methods: {
    onSubmit(values) {
      console.log('submit', values);
      httpApi.RouteApi.add(this.form).then(res=>{
        console.log(res);
      })
      this.$router.push('/explore')
    },
  },
  }
</script>

<style lang="scss" scoped>

</style>